use use "C:\Users\mjoshi2\Box\2023 Research\Rebel victories\Feb2022-02-16\RR\Replicatonfile\TPG_Reb_Vic (Sharif & Joshi 2023).dta", replace
log using "C:\Users\mjoshi2\Box\2023 Research\Rebel victories\Feb2022-02-16\RR\Replicatonfile\TPG_Reb_Vic-Replicationcode.smcl", replace

set seed 123456

sort mj_caseid year

//Manuscript Table 1
//Model 1
xtlogit conflict_binary L.cum_provisions L.sanctions_full L.embargobinary 	///
L.ln_pop_fill L.polity L.hdi L.time_1 L.insurg_external_sup L.war_int_high_low  if mj_caseid!=8, vce(robust)
test

//Model 2
 xtlogit conflict_binary L.cum_peace_mj  L.sanctions_full L.embargobinary  ///
   L.ln_pop_fill L.polity L.hdi L.time_1 L.insurg_external_sup L.war_int_high_low if mj_caseid!=8, vce(robust)
test
//Model 3
 xtlogit conflict_binary L.cum_const  L.sanctions_full L.embargobinary  ///
   L.ln_pop_fill L.polity L.hdi L.time_1 L.insurg_external_sup L.war_int_high_low if mj_caseid!=8, vce(robust)
 test  
//Model 4
 xtlogit conflict_binary L.cum_powershare_either L.sanctions_full L.embargobinary  ///
   L.ln_pop_fill L.polity L.hdi L.time_1 L.insurg_external_sup L.war_int_high_low if mj_caseid!=8, vce(robust)
  test 
 
 //Model 5
  xtlogit conflict_binary L.gd_ptsa L.sanctions_full L.embargobinary  ///
   L.ln_pop_fill L.polity L.hdi L.time_1 L.insurg_external_sup L.war_int_high_low if mj_caseid!=8, vce(robust)
   test
 //Model 6
 xtlogit conflict_binary L.cum_provisions L.cum_peace_mj L.cum_const L.cum_powershare_either L.gd_ptsa L.sanctions_full L.embargobinary  ///
   L.ln_pop_fill L.polity L.hdi L.time_1 L.insurg_external_sup L.war_int_high_low if mj_caseid!=8, vce(robust)
   
  test
  
   //Margins Plot after Model 6
 gen MYVAR = cum_provisions
 xtlogit conflict_binary L.MYVAR L.cum_peace_mj L.cum_const L.cum_powershare_either L.gd_ptsa L.sanctions_full L.embargobinary  ///
   L.ln_pop_fill L.polity L.hdi L.time_1 L.insurg_external_sup L.war_int_high_low if mj_caseid!=8, vce(robust)
 margins, atmeans at(L.MYVAR =(0(1)5)) saving (file1, replace)
 
 drop MYVAR
 
 gen MYVAR = gd_ptsa
 xtlogit conflict_binary L.cum_provisions L.cum_peace_mj L.cum_const L.cum_powershare_either L.MYVAR L.sanctions_full L.embargobinary  ///
   L.ln_pop_fill L.polity L.hdi L.time_1 L.insurg_external_sup L.war_int_high_low if mj_caseid!=8, vce(robust)
   
 margins, atmeans at(L.MYVAR =(1(1)5)) saving (file2, replace)
 
 combomarginsplot file1 file2, labels("Cumulative constitutional reforms in peace agreement" "Political terror scale") xtitle("")
  drop MYVAR

 //Appendix Table 1 Summary Statistics
sum conflict_binary active_dyad L.cum_provisions L.cum_peace_mj L.cum_const L.cum_powershare_either L.gd_ptsa L.sanctions_full L.embargobinary  ///
   L.pop_density_fill L.ln_pop_fill L.polity L.hdi L.time_1 L.insurg_external_sup L.war_int_high_low L.coup if mj_caseid!=8 &data_used==1
 
 //Appendix Table 2
 
pwcorr conflict_binary active_dyad L.cum_provisions L.cum_peace_mj L.cum_const L.cum_powershare_either L.gd_ptsa L.sanctions_full L.embargobinary  ///
   L.pop_density_fill  L.ln_pop_fill L.polity L.hdi L.time_1 L.insurg_external_sup L.war_int_high_low L.coup if mj_caseid!=8 &data_used==1


//Appendix Table 3 generalized linear model with panels iid and correlation 
//Model 1
//Appendix Table 3 generalized linear model with panels iid and correlation 
//Model 1
xtgls  active_dyad L.cum_provisions L.sanctions_full L.embargobinary 	///
L.ln_pop_fill L.polity L.hdi L.time_1 L.ext_count L.war_int_high_low  if mj_caseid!=8, panels(iid) corr(psar1)
test

//Model 2
xtgls  active_dyad L.cum_peace_mj  L.sanctions_full L.embargobinary  ///
   L.ln_pop_fill L.polity L.hdi L.time_1 L.ext_count L.war_int_high_low if mj_caseid!=8, panels(iid) corr(psar1)
test
//Model 3
 xtgls  active_dyad L.cum_const  L.sanctions_full L.embargobinary  ///
   L.ln_pop_fill L.polity L.hdi L.time_1 L.ext_count L.war_int_high_low if mj_caseid!=8, panels(iid) corr(psar1)
 test  
//Model 4
xtgls  active_dyad L.cum_powershare_either L.sanctions_full L.embargobinary  ///
   L.ln_pop_fill L.polity L.hdi L.time_1 L.ext_count L.war_int_high_low if mj_caseid!=8, panels(iid) corr(psar1)
  test 
 
 //Model 5
xtgls  active_dyad L.gd_ptsa L.sanctions_full L.embargobinary  ///
   L.ln_pop_fill L.polity L.hdi L.time_1 L.ext_count L.war_int_high_low if mj_caseid!=8, panels(iid) corr(psar1)
   test
 //Model 6
xtgls  active_dyad L.cum_provisions L.cum_peace_mj L.cum_const L.cum_powershare_either L.gd_ptsa L.sanctions_full L.embargobinary  ///
   L.ln_pop_fill L.polity L.hdi L.time_1 L.ext_count L.war_int_high_low if mj_caseid!=8, panels(iid) corr(psar1)
  test

  //Appendix Table 4   Includes population density and coup and leave sout population variable
 
//Model 1
xtlogit conflict_binary L.cum_provisions L.sanctions_full L.embargobinary  L.pop_density_fill	L.coup 	///
L.polity L.hdi L.time_1 L.insurg_external_sup L.war_int_high_low  if mj_caseid!=8, vce(robust)
test

//Model 2
 xtlogit conflict_binary L.cum_peace_mj  L.sanctions_full L.embargobinary L.pop_density_fill L.coup  ///
 L.polity L.hdi L.time_1 L.insurg_external_sup L.war_int_high_low if mj_caseid!=8, vce(robust)
test
//Model 3
 xtlogit conflict_binary L.cum_const  L.sanctions_full L.embargobinary  L.pop_density_fill	L.coup ///
   L.polity L.hdi L.time_1 L.insurg_external_sup L.war_int_high_low if mj_caseid!=8, vce(robust)
 test  
//Model 4
 xtlogit conflict_binary L.cum_powershare_either L.sanctions_full L.embargobinary L.pop_density_fill L.coup  ///
  L.polity L.hdi L.time_1 L.insurg_external_sup L.war_int_high_low if mj_caseid!=8, vce(robust)
  test 
 
 //Model 5
  xtlogit conflict_binary L.gd_ptsa L.sanctions_full L.embargobinary L.pop_density_fill	L.coup  ///
   L.polity L.hdi L.time_1 L.insurg_external_sup L.war_int_high_low if mj_caseid!=8, vce(robust)
   test
 //Model 6
 xtlogit conflict_binary L.cum_provisions L.cum_peace_mj L.cum_const L.cum_powershare_either L.gd_ptsa ///
 L.sanctions_full L.embargobinary  L.pop_density_fill	L.coup ///
   L.polity L.hdi L.time_1 L.insurg_external_sup L.war_int_high_low if mj_caseid!=8, vce(robust)
   
  test

  //Table 5 Appendix Replicates Model 4 and 6 in the main table with jouinor partner variables  
   
//Model 4
xtlogit conflict_binary L.juniorpartner_size L.sanctions_full L.embargobinary L.pop_density_fill L.coup  ///
  L.polity L.hdi L.time_1 L.insurg_external_sup L.war_int_high_low if mj_caseid!=8, vce(robust)
  test 
 
  //Model 6
xtlogit conflict_binary L.cum_provisions L.cum_peace_mj L.cum_const L.juniorpartner_size L.gd_ptsa L.sanctions_full L.embargobinary  L.pop_density_fill	L.coup ///
   L.polity L.hdi L.time_1 L.insurg_external_sup L.war_int_high_low if mj_caseid!=8, vce(robust)  
   
   test  

//Table 6 Appendix Replicates Model 4 and 6 in the main table with interaction between rebel tenure and terror scale 
  //Model 4
 xtlogit conflict_binary L.gd_ptsa L.sanctions_full L.embargobinary  ///
   L.ln_pop_fill L.polity L.hdi L.time_1 L.insurg_external_sup L.war_int_high_low time_1_gd_ptsa if mj_caseid!=8, vce(robust)
   test
  
  //Model 6
 xtlogit conflict_binary L.cum_provisions L.cum_peace_mj L.cum_const L.cum_powershare_either L.gd_ptsa L.sanctions_full L.embargobinary  ///
   L.ln_pop_fill L.polity L.hdi L.time_1 L.insurg_external_sup L.war_int_high_low time_1_gd_ptsa if mj_caseid!=8, vce(robust)
   
  test 
   
 log close
